<!doctype html>
<html>
<head>
    <meta charset="UTF-8"/>
    <title>feb</title>
    <link rel="stylesheet" type="text/css" href="/webapp/css/easyui.css">
    <link rel="stylesheet" type="text/css" href="/webapp/css/icon.css">
    <link rel="stylesheet" type="text/css" href="/webapp/css/color.css">
    <link rel="stylesheet" type="text/css" href="/webapp/css/public.css">
    <link rel="shortcut icon" href="/webapp/favicon.ico"/>
    <script type="text/javascript" src="/webapp/js/lib/jquery.min.js"></script>
    <script type="text/javascript" src="/webapp/js/lib/jquery.easyui.min.js"></script>
    <script type="text/javascript" src="/webapp/js/lib/ajaxfileupload.js"></script>
    <script type="text/javascript" src="/webapp/js/common/config.js"></script>
    <script type="text/javascript" src="/webapp/js/main/main.js"></script>
</head>
<body class="easyui-layout">
<div data-options="region:'north',border:false" style="padding-bottom: 0px;">
    <div class="web-header  "style="padding-bottom: 0.2%;padding-top: 0.9% "  >
    <!--<div class="web-header clearfix " >-->

        <div class="user-info fr">
            <a href="javascript:void(0);" id="username">admin</a>|
            <a href="javascript:void(0);" onclick="openWindow()">修改密码</a>|
            <a href="javascript:void(0);" class="btn-logout">退出</a>
        </div>
        <div class="month-week fr">

            <select class="easyui-combobox" id ="data-mode" data-options="panelHeight:'auto'" style="width: 93%;">
                <option value="month">月报模式</option>
                <option value = "week">周报模式</option>
                <option value = "online">电商模式(周)</option>
                <option value = "online_m">电商模式(月)</option>
                <option value = "PDK_W">拼抖快专用(周)</option>
                <option value = "PDK_M">拼抖快专用(月)</option>
            </select>
        </div>
        <a class="logo"  style=" letter-spacing:2px; color:#0E2D5F ">泛博瑞 RAW DATA 数据清洗系统</a>
        <!--FEB RAW DATA 数据清洗系统-->
    </div>
</div>
<div data-options="region:'west',split:true,collapse:true,title:'主菜单'" style="width:172px;height: 100%">
    <div id="menu" class="easyui-accordion" data-options="fit:true,border:false,nimate:true,lines:true">

    </div>
</div>
<div data-options="region:'south',border:false">
    <div class="web-footer">
        <h6>Copyright &copy; 2018-2021 FEB Consulting Group All Rights Reserved</h6>
    </div>

</div>
<div data-options="region:'center'" style="border:none;">
    <div id="tabs" class="easyui-tabs" style="width:100%;height:100%;border:none;">
        <div title="系统首页" style="width:100%;height:100%;">
            <iframe name="homePage" scrolling="auto" frameborder="0" src="./index.html" style="width:100%;height:100%;display:block;"></iframe>
        </div>
    </div>
</div>
<div id="w" class="easyui-window form-wrapper" title="修改密码" data-options="modal:true,closed:true,iconCls:'icon-save'" style="padding:10px;width:400px;height:280px;">
    <form id="window-form" class="form-box">
        <div style="margin-bottom:20px;">
            <label class="item-label">原始密码：</label>
            <input type="password" class="easyui-passwordbox" name="password" data-options="required:true" />
        </div>
        <div style="margin-bottom:20px;">
            <label class="item-label">新密码：</label>
            <input type="password" class="easyui-passwordbox" name="newpassword" data-options="required:true" />
        </div>
        <div style="margin-bottom:20px;">
            <label class="item-label">重复密码：</label>
            <input type="password" class="easyui-passwordbox" name="confirmpassword" data-options="required:true" />
        </div>
        <div style="margin-bottom:20px;text-align:center;">
            <a href="javascript:void(0);" onclick="submitForm()" class="easyui-linkbutton c8" style="width:80px;">提交</a>
            <a href="javascript:void(0);" onclick="clearForm()" class="easyui-linkbutton" style="width:80px;">重置</a>
        </div>
    </form>
</div>
</body>
<script type="text/javascript">
    $(function(){
        $(".btn-logout").on("click",function(e){
            logout();
        });
        window.userName=$('#username').text();
    })
    function openWindow(){
        $("#w").window("open");
    }
    function submitForm(){
        $("#window-form").form("submit",{
            onSubmit:function () {
                var valid = $(this).form('enableValidation').form('validate');
                if(valid){
                    var data = getFormData(document.getElementById("window-form"));
                    if(data.newpassword!=data.confirmpassword){
                        $.messager.alert("提示","两次密码不一致","error");
                        return false;
                    }
                    $.ajax({
                        url:config.url+"/user/updatePassword",
                        type:'post',
                        data:data,
                        xhrFields:{withCredentials:true},
                        success:function(data){
                            if(data){
                                $.messager.alert("提示","操作成功","info",function () {
                                    $("#w").window("close");
                                });
                            }
                        },
                        error:function (data) {
                            if("error"==data.statusText){
                                window.location.href="/webapp";
                            }
                        }
                    });
                    return false;
                }
                return false;
            }
        });
    }
    function clearForm(){
        $("#window-form").form("reset");
    }
    setInterval(function() {
        var v=$('#username').text();
        if(v){
            if (v=="zwn"){
                condition();
            }
        }

    }, 7200000)
    // }, 5000)
    setTimeout(function() {
        window.userName=$('#username').text();
        var v=$('#username').text();
        if(v){
            if (v=="zwn"){
                condition();
            }
        }

    }, 5000)
    function condition() {
        // alert("查询了")
        var dtd = $.Deferred();
        $.ajax({
            url: config.url + "/modifyRecord/getAll",
            type: 'get',
            contentType:"application/json;charset=UTF-8",

            xhrFields: {withCredentials: true},
            success: function (data) {
                if (data.code==200) {
                    alert(data.msg)
                    dtd.resolve();
                }
            },
            error: function (XMLHttpRequest, textStatus, errorThrown) {
                dtd.reject();
            }
        });
        return dtd.promise();
    }

</script>
</html>
